#include "head_client.h"
#define LENGTH 4096 //每次内存复制的大小，必须是4096的整数倍

int main(int argc, char *argv[])
{
    ARGS_CHECK(argc, 2);
    char *ip="192.168.181.128";
    char *port="8080";
    int socketfd=socket(AF_INET,SOCK_STREAM,0);
    struct sockaddr_in addr;
    addr.sin_family=AF_INET;
    addr.sin_port=htons(atoi(port));
    addr.sin_addr.s_addr=inet_addr(ip);
    //客户端请求与服务端建立连接
    connect(socketfd,(struct sockaddr *)&addr,sizeof(addr));
    //----------------------------------------------------------------
    //客户端请求登录，如果连续输入三次错误的密码则会主动退出
    login_in(socketfd);
    //----------------------------------------------------------------
    //客户端告诉服务端要获取文件的文件名
    char name[1024] = {0};
    strcpy(name, argv[1]);
    int len = strlen(name);

    send(socketfd, &len, sizeof(len), 0);
    send(socketfd, name, len, 0);
    //send_bigfile(socketfd, name);
    recv_bigfile(socketfd, name);

    close(socketfd);
    return 0;
}

